package com.mobileduty.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.mobileduty.R;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;

/**
 * 消息界面
 */

public class MessageFragment extends Fragment {
    private Context context;
    private View view;
    private ImageView titlebar_back;
    private TextView titlebar_title;
    private ImageView titlebar_other;


    private RecyclerView message_recyler;
    private ArrayList<String> arrayList;
    private CommonAdapter<String> commonAdapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.message_main, container, false);
        initView(view);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    private void initView(View view) {
        context = getActivity();
        titlebar_back = (ImageView) view.findViewById(R.id.titlebar_back);
        titlebar_back.setVisibility(View.GONE);
        titlebar_title = (TextView) view.findViewById(R.id.titlebar_title);
        titlebar_title.setText("设备消息");
        titlebar_other = (ImageView) view.findViewById(R.id.titlebar_other);
        titlebar_other.setVisibility(View.GONE);

        message_recyler = (RecyclerView) view.findViewById(R.id.message_recyler);
        arrayList = new ArrayList();
        for (int i = 0; i < 10; i++) {
            arrayList.add("");
        }
        commonAdapter = new CommonAdapter<String>(context, R.layout.message_item, arrayList) {
            @Override
            protected void convert(ViewHolder holder, String s, int position) {

            }
        };
        message_recyler.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
        message_recyler.setAdapter(commonAdapter);
    }
}